<template>
  <el-select v-model="cangkukeyid" size="small" style="width:100%" filterable clearable @change="returnChange" placeholder="请选择仓库" >
    <el-option 
      v-for="item in cangkus" 
      :key="item.cangkuId" 
      :label="item.cangkuName" 
      :value="item.cangkuId">
    </el-option>
  </el-select>
</template>

<script>
import { listCangku } from "@/api/erp/system/cangku";

export default {
  data() {
    return {
      cangkus:[],
      cangkukeyid : '',
    };
  },
  model:{
    prop:'cangkuId',
    event: 'change'
  },
  watch:{
    cangkuId : function(newValue, oldValue){
      this.cangkukeyid = newValue;
    }
  },
  props: {
    //用于绑定和初始选中的仓库ID
    cangkuId : 0,
    //所属公司
    dictCode : 0,
    //仓库类型，原料、成品、轧辊、其他等
    cangkuProperty : 0,
  },
  methods: {
    returnChange(){
      this.$emit('change', this.cangkukeyid);
    },
  },
  created() {
    listCangku({dictcode : this.dictCode, cangkuProperty : this.cangkuProperty}).then(response => {
      this.cangkus = response.rows;
    });
  },
  mounted(){
  },
};
</script>
